package com.welove.activity.login;

import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

import com.welove.R;
import com.welove.activity.BaseActivity;
import com.welove.widget.ChoosePicPopupWindow;

/**
 * @ClassName: RegisterPerfectInfoActivity
 * @Description: 完善资料界面
 * @author: dreamfutureba@gmail.com
 * @date: 2013年11月7日 下午1:14:19
 */
public class RegisterPerfectInfoActivity extends BaseActivity{
	private static final String TAG=RegisterPerfectInfoActivity.class.getSimpleName();
	
	private ImageView register_perfect_info_choose_photo;
	private TextView register_perfect_info_choose_photo_tv;
	
	private RadioGroup register_perfect_info_sex_group;
	private RadioButton register_perfect_info_rb_male;
	private RadioButton register_perfect_info_rb_female;
	
	private Button register_btn_next_confirm;
	
	//自定义的弹出框类
	private ChoosePicPopupWindow menuPopupWindow;
	
	
	@Override
	protected void installViews() {
		setContentView(R.layout.activity_register_perfect_info);
		findView();
	}
	
	private void findView(){
		//头像选择
		register_perfect_info_choose_photo=(ImageView) this.findViewById(R.id.register_perfect_info_choose_photo);
		register_perfect_info_choose_photo_tv=(TextView) this.findViewById(R.id.register_perfect_info_choose_photo_tv);
		//性别选择
		register_perfect_info_sex_group=(RadioGroup) this.findViewById(R.id.register_perfect_info_sex_group);
		register_perfect_info_rb_male=(RadioButton) this.findViewById(R.id.register_perfect_info_rb_male);
		register_perfect_info_rb_female=(RadioButton) this.findViewById(R.id.register_perfect_info_rb_female);
		//下一步
		register_btn_next_confirm=(Button) this.findViewById(R.id.register_btn_next_confirm);
		
	}

	@Override
	protected void registerEvents() {
		//选择头像
		register_perfect_info_choose_photo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				//实例化ChoosePicPopupWindow
				menuPopupWindow=new ChoosePicPopupWindow(RegisterPerfectInfoActivity.this, 
						itemsOnClick);
				//显示窗口
				menuPopupWindow.showAtLocation(RegisterPerfectInfoActivity.this.findViewById(R.id.register_perfect_info), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); //设置layout在PopupWindow中显示的位置
			}
		});
		//性别选择
		register_perfect_info_sex_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				
			}
		});
		//下一步
		register_btn_next_confirm.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
	//为弹出窗口实现监听类
    private OnClickListener  itemsOnClick =new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			menuPopupWindow.dismiss();
			switch (v.getId()) {
			case R.id.view_choose_from_camera:
				Toast.makeText(getApplicationContext(), "拍照", Toast.LENGTH_SHORT).show();
				break;
			case R.id.view_choose_from_albums:
				Toast.makeText(getApplicationContext(), "从相册选择", Toast.LENGTH_SHORT).show();
				break;
			default:
				break;
			}
			
		}
	};
	
	@Override
	protected void initTitleBar() {
		super.initTitleBar();
		mTitleBar.titlebar_tv_center.setText("完善资料");
		mTitleBar.titlebar_btn_right.setVisibility(View.GONE);
	}
}
